package shiyan2;

public class Student1 implements Comparable<Student1> {
    private String name;
    private int age;
    public Student1(){}

    public Student1(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return "shiyan2.Student1{"+"name="+name+'\''+",age="+age+'}';

    }
    @Override
    public int compareTo(Student1 o) {
        if (this.getAge()<o.getAge()) {
            return -1;
        }else if(this.getAge()>o.getAge()) {
            return 1;
        }else {
            return 0;
        }
    }
}
